package gov.pbc.nn.kjgl.jfcr.handler;

import gov.pbc.nn.core.bdf.entity.Dept;
import gov.pbc.nn.core.utils.SecurityUtils;
import gov.pbc.nn.kjgl.Constants;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.stereotype.Component;

import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.context.ContextHolder;
import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.process.handler.AssignmentHandler;
import com.bstek.uflo.process.node.TaskNode;

/**
 * 机房补录审批的handler
 * 
 * @author jack.zhao
 * 
 */
@Component("jfgl.AssignmentHandler")
public class JfglAssignmentHandler implements AssignmentHandler {

	@Override
	public Collection<String> handle(TaskNode node, ProcessInstance processInstance, Context context) {
		List<String> users = new ArrayList<String>();
		Dept dept = (Dept) ContextHolder.getLoginUser().getDepts().get(0);
		List<IUser> jgUsers = SecurityUtils.getUserByRoleForDeptWithChildren(dept.getCDept().getId(), Constants.ROLE_JFGLY);
		if (jgUsers.size() > 0) {
			users.add(jgUsers.get(0).getUsername());
		}
		return users;
	}
}
